<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	<h:head>
		<title>Add User</title>
		<h:outputStylesheet library="css" name="main.css" />
	</h:head>
	<h:body>
		<!-- addUser page only visible to logged-in Admin -->
		<h:panelGroup rendered="#{loginSession.isAdmin()}">
		
			<ui:insert name="header" >
		  		<ui:include src="/templates/header.xhtml" />
			</ui:insert>
			
			<h:form>
				<div>
					<h:outputText value="#{msgs.firstname}"/>
					<h:inputText value="#{credentials.firstName}"/>
				</div>
				
				<div>
					<h:outputText value="#{msgs.lastname}"/>	
					<h:inputText value="#{credentials.lastName}"/>
				</div>
				
				<div>
					<h:outputText value="#{msgs.username}"/>	
					<h:inputText value="#{credentials.username}"/>
				</div>
				
				<div>
					<h:outputText value="#{msgs.password}"/>	
					<h:inputText value="#{credentials.password}"/>
				</div>
				
				<div>
					<h:outputText value="#{msgs.admin}"/>
					<h:selectBooleanCheckbox value="#{credentials.admin}"/>
				</div>
				
				<h:commandButton value="#{msgs.submit}" action="#{usermanager.addUser()}" />
			</h:form>
		</h:panelGroup>
		
		<!-- Not logged-in viewers will be able to view this section -->
		<h:panelGroup rendered="#{!loginSession.isLoggedIn()}">
			<ui:insert name="notLogIn" >
		  		<ui:include src="/templates/notLogIn.xhtml" />
			</ui:insert>
		</h:panelGroup>
		
		<!-- Logged-in non-admin will be able to view this section -->
		<h:panelGroup rendered="#{!loginSession.isAdmin()}">
			<ui:insert name="notAdmin" >
		  		<ui:include src="/templates/notAdmin.xhtml" />
			</ui:insert>
		</h:panelGroup>
	</h:body>
</html>
